

$('#login').click(function () {
    localStorage.removeItem('uid')
    console.log($('#login').html());

    $('.kuang').show()
    if ($('#login').html() == '退出登录') {
        location.reload()
    }

})

$('.div').hover(function () {


    $('.span').css({

        transform: 'rotate(180deg)'
    })
    $('.slide_down').css({ display: 'flex' })

}, function () {
    $('.slide_down').hide()
    $('.span').css({

        transform: 'rotate(360deg)'
    })

})


$('#nav li').hover(function () {
    $(this).css({
        borderBottom: '4px solid yellow',
        color: 'white',
    })
}, function () {
    $(this).css({
        border: 'none',
        color: 'rgb(170, 170, 170)',
    })
})


window.onscroll = function () {
    let h = document.documentElement.scrollTop


    if (h > 400) {
        $('#top').css({
            position: 'sticky',
            top: 0,
            zIndex: ' 5555',
            display: 'block'
        })



    } else {

        $('#top').css({
            position: 'relative',
            top: ' 0',
            zIndex: ' 5555',
        })
    }
}




//发送请求

function get() {
    $('#log-btn').click(function () {
        let username = $('#log-btn').prev().prev().prev().prev().val()
        let password = $('#log-btn').prev().prev().val()
        console.log(username, password);
        if ($(this).html() == '注册') {
            $.get('http://jx.xuzhixiang.top/ap/api/reg.php', { username, password }, function (res) {
                console.log(res)
                if (res.code == 0) {
                    alert('用户名存在')
                } else {
                    alert('注册成功')

                    location.reload()
                }
            }, 'json')
        }
        if ($(this).html() == '登录') {
            $.get('http://jx.xuzhixiang.top/ap/api/login.php', { username, password }, function (res) {
                if (res.code == 0) {
                    alert('密码错误')
                } else {
                    alert('登录成功')
                    let uid = res.data.id
                    let data = [{ "a": 1 }]
                    y = JSON.stringify(data)
                    $.get('http://localhost:3000/card', function (res) {
                        // console.log(res);
                        let flag = true

                        res.forEach(v => {
                            if (v.uid == uid) {
                                flag = false

                            }
                        })
                        if (flag) {
                            $.post('http://localhost:3000/card', { uid, data: y })
                        }

                    })

                    localStorage.setItem('uid', uid)
                    location.reload()
                }
            }, 'json')
        }
    })
}






$('.slide_top').click(function () { $('html,body').animate({ scrollTop: '0px' }, 400); });
$('.glyphicon-download').click(function () { $('html,body').animate({ scrollTop: '10500px' }, 400); });
var obj;
$('#aside>div').hover(function () {
    $(this).find('section').show()
}, function () {
    $(this).find('section').hide()

})


$('.cart').click(function () {

    location.href = 'mycar.html'
})